import { Base } from '../../utils/base.js';

class Order extends Base {
    constructor() {
        super()
    }
    //获取订单
    getOrder(params, callback) {
        let url = '/ddaigo-platform/order/list'
        var reType = 'POST';
        this.commonRequest(url, reType, params, callback);
    }
    //删除订单
    deleteOrder(params, callback) {
        let url = '/ddaigo-platform/order/delete'
        var reType = 'POST';
        this.commonRequest(url, reType, params, callback);
    }
    // 获取不同订单数量
    getOrderCount(params, callback) {
        let url = '/ddaigo-platform/order/getOrderCount'
        var reType = 'POST';
        this.commonRequest(url, reType, params, callback);
    }
    //退款
    wxRefund(params, callback) {
        // let url = "/ddaigo-platform/refund/refund";
        let url = "/ddaigo-platform/refund/refundAudit";
        var reType = 'POST';
        this.commonRequest(url, reType, params, callback);
    }
    // 根据id获取单个地址
    getUserAddressById(params, callback) {
        var url = '/ddaigo-platform/user/getUserAddressById';
        var reType = 'POST';
        this.commonRequest(url, reType, params, callback);
    }
    // 减库存接口
    reduceGoodsStock(params, callback) {
        var url = '/ddaigo-platform/order/reduceGoodsStock'
        var reType = 'POST';
        this.commonRequest(url, reType, params, callback);
    }
    commonRequest(url, reType, params, callback) {
        var that = this;
        var param = {
            url: url,
            type: reType,
            data: params,
            sCallback: function (data) {
                typeof callback == 'function' && callback(data);
            },
            eCallback: data => {
                callback && callback({ status: false, data: data });
            }
        };
        this.request(param);
    }

    formate(fmt, data) {
        var data = data ? data : 'yyyy-MM-dd hh:mm:ss'
        return (new Date(fmt)).cartFormat(data)
    }
}
module.exports = {
    Order
}